980A - Links and Pearls - CodeForces Solution


implementation math *900

Please click on ads to support us..

Python Code:

necklace = input()
 
if necklace.count('o') == 0:
    print("YES")
elif necklace.count('-') % necklace.count('o') == 0:
    print("YES")
else:
    print("NO")

C++ Code:

#include<bits/stdc++.h>
#define int long long 
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define pre(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
const int INF=0x3f3f3f3f,mod=1e9+7;

void solve(){
	string s;
	cin>>s;
	int x=0,y=0;
	rep(i,0,s.size()-1){
		if(s[i]=='-')x++;
		else y++;
	}
	if(x==0||y==0)cout<<"YES";
	else if(x%y==0)cout<<"YES";
	else cout<<"NO";
}

signed main(){ 
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	solve();
    return 0;
}
/*
2 0
1 3

*/
	 	  	  						  	 	     			 	 	


Comments

Submit
0 Comments
More Questions

963A - Alternating Sum
1191B - Tokitsukaze and Mahjong
1612G - Max Sum Array
1459B - Move and Turn
1006F - Xor-Paths
706C - Hard problem
304C - Lucky Permutation Triple
1301C - Ayoub's function
38E - Let's Go Rolling
171G - Mysterious numbers - 2
1183C - Computer Game
400C - Inna and Huge Candy Matrix
417A - Elimination
222A - Shooshuns and Sequence
1736A - Make A Equal to B
1736B - Playing with GCD
887C - Solution for Cube
1737C - Ela and Crickets
1741C - Minimize the Thickness
1741A - Compare T-Shirt Sizes
1741D - Masha and a Beautiful Tree
109B - Lucky Probability
1741B - Funny Permutation
1741E - Sending a Sequence Over the Network
344B - Simple Molecules
370A - Rook Bishop and King
546E - Soldier and Traveling
1741G - Kirill and Company
1200B - Block Adventure
1088B - Ehab and subtraction